package javasec.contempt.actions;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction;

public class VisualsViewAction extends Action implements ISelectionListener,
		IWorkbenchAction
{
	private final IWorkbenchWindow window;
	public final static String ID="javasec.contempt.actions.VisualsViewAction";
	//private IStructuredSelection selection;
	
	public VisualsViewAction(IWorkbenchWindow window)
	{
		this.window=window;
		setId(ID);
		setText("Visuals");
		setToolTipText("santa43622");
		
		window.getSelectionService().addSelectionListener(this);
	}
	
	public void selectionChanged(IWorkbenchPart part, ISelection selection)
	{
		
	}

	public void dispose()
	{
		window.getSelectionService().removeSelectionListener(this);
	}

	public void run()
	{
		System.out.println("action run has been called");
		IWorkbenchPage page = window.getActivePage();
		System.out.println("isn't it amazing?");
		
		try
		{
			System.out.println("opening new editor");
			page.showView("javasec.contempt.views.VisualsView");
		}
		catch(PartInitException e)
		{
			System.out.println(e);
			//
		}
		finally
		{
			//
		}
		//Object item=selection.getFirstElement();
		//ContactsEntry entry = (ContactsEntry)item;
	}
}
